package com.lzw.utils;

import com.lzw.app.Instance;

/**
 * 日志输出工具
 * @author LZW
 */
public class LogUtils {
    private LogUtils() {
    }

    public static void printLogAdd(StringBuilder sb) {
        sb.append("\n\t").append("请求动作：【服务注册】");
    }

    public static void printLogPing(StringBuilder sb) {
        sb.append("\n\t").append("请求动作：【续约】");
    }

    public static void printLogFetch(StringBuilder sb) {
        sb.append("\n\t").append("请求动作：【服务订阅】");
    }

    public static void printLogServerAdd(StringBuilder sb) {
        sb.append("\n\t").append("请求动作：【集群注册】");
    }

    public static void printLogAccepted(StringBuilder sb) {
        sb.append("《").append(Thread.currentThread().getName()).append("》监听到请求===>>").append("\t").append(DateUtils.nowTime());
    }

    public static void printLogInstanceRegisterSuccess(Instance instance, StringBuilder sb) {
        sb.append("\n\t\tlog: ").append(instance.getName()).append(" 完成了服务注册").append("\n\r\t\t").append("url: ").append(instance.getUrl());
    }

    public static void printLogServerRegisterSuccess(Instance instance, StringBuilder sb) {
        sb.append("\n\t\tlog: ").append(instance.getName()).append(" 完成了集群注册").append("\n\r\t\t").append("url: ").append(instance.getUrl());
    }

    public static void printLogFetchSuccess(Instance instance, String status, StringBuilder sb) {
        sb.append("\n\t\tlog: ").append(instance.getName()).append(" 完成了服务订阅").append("\n\r\t\t").append("url: ").append(instance.getUrl()).append("\n\r\t\t状态: ").append(status);
    }

    public static void printLogRenewSuccess(Instance instance, StringBuilder sb) {
        sb.append("\n\t\tlog: ").append(instance.getName()).append(" 完成了续约").append("\n\r\t\t").append("url: ").append(instance.getUrl());
    }

    public static void printLogBadRequest(StringBuilder sb) {
        sb.append("\t\tlog: 无法识别的请求");
    }

    public static void printLogClear(String type, StringBuilder sb) {
        sb.append("===执行").append(type).append("无效剔除===  time:").append(DateUtils.nowTime());
    }

    public static void printLogRemoveById(String id, StringBuilder sb) {
        sb.append("\t删除--->> id: ").append(id);
    }

    public static void printLogRemoveByName(String name, StringBuilder sb) {
        sb.append("\t删除--->> name: ").append(name);
    }

    public static void printLogPingPong(StringBuilder sb) {
        sb.append("我还活着--").append(DateUtils.nowTime());
    }
}
